#include "wx/wxprec.h"

#ifdef __BORLANDC__
#pragma hdrstop
#endif

#ifndef WX_PRECOMP
#include "wx/wx.h"
#include "wx/log.h"
#endif



#include "oxDefs.h"
#include "Tree.h"
#include "Hierarchy.h"

IMPLEMENT_DYNAMIC_CLASS(Hierarchy, oxTreeCtrl)

BEGIN_EVENT_TABLE(Hierarchy, oxTreeCtrl)

EVT_TREE_BEGIN_DRAG(oxHierarchy_Ctrl, Hierarchy::OnBeginDrag)
EVT_TREE_END_DRAG(oxHierarchy_Ctrl, Hierarchy::OnEndDrag)
EVT_TREE_BEGIN_LABEL_EDIT(oxHierarchy_Ctrl, Hierarchy::OnBeginLabelEdit)
EVT_TREE_END_LABEL_EDIT(oxHierarchy_Ctrl, Hierarchy::OnEndLabelEdit)

EVT_TREE_SEL_CHANGED(oxHierarchy_Ctrl, Hierarchy::OnSelChanged)

END_EVENT_TABLE()


Hierarchy* Hierarchy::hierarchy = NULL;

Hierarchy::Hierarchy(wxWindow *parent, const wxWindowID id)
: oxTreeCtrl(parent, id)
{
	hierarchy = this;

	AddRoot(wxT("Root"));
}

void Hierarchy::OnBeginDrag(wxTreeEvent& event)
{
	oxTreeCtrl::OnBeginDrag(event);
}

void Hierarchy::OnEndDrag(wxTreeEvent& event)
{
	oxTreeCtrl::OnEndDrag(event);
	
}

void Hierarchy::OnBeginLabelEdit(wxTreeEvent& event)
{
	wxLogMessage(wxT("OnBeginLabelEdit"));

}

void Hierarchy::OnEndLabelEdit(wxTreeEvent& event)
{
	wxLogMessage(wxT("OnEndLabelEdit"));

	
}

void Hierarchy::OnSelChanged(wxTreeEvent& event)
{
	oxTreeCtrl::OnSelChanged(event);
}

wxTreeItemId Hierarchy::AppendItem(const wxTreeItemId &parent, float x, float y)
{
	if (parent) 
	{
		return oxTreeCtrl::AppendItem(parent, wxT("GameObject"), -1, -1, new HierarchyItemData(x, y));
	}
	else
	{
		return oxTreeCtrl::AppendItem(GetRootItem(), wxT("GameObject"), -1, -1, new HierarchyItemData(x, y));
	}
}